/*
 * Circuit.hpp
 *
 * Copyright 2012 Pieter Agten
 *
 * This file is part of tltgen.
 *
 * tltgen is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * tltgen is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with tltgen.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @file   Circuit.hpp
 * @author Pieter Agten (pieter.agten@gmail.com)
 * @date   28 feb 2012
 * @brief  The abstract Circuit class defines the interface concrete 
 *         circuits must adhere to.
 */

#ifndef CIRCUIT_HPP
#define CIRCUIT_HPP

#include <boost/lexical_cast.hpp>
#include <boost/serialization/access.hpp>
#include <boost/serialization/version.hpp>

#include "Resistance.hpp"
#include "Temperature.hpp"
#include "Voltage.hpp"
#include "Power.hpp"

#include "SerializationException.hpp"

namespace tltgen {
  
  class CircuitVisitor;
  class Circuit {
  public:
    virtual ~Circuit();

    /**
     * Returns whether a given voltage is a valid output voltage for this 
     * circuit model.
     *
     * @param  voltage the voltage to check
     * @return whether a given voltage is a valid output voltage for this 
     *         circuit model
     */
    virtual bool isValidOutputVoltage(Voltage voltage) const = 0;

    virtual Resistance getThermistorResistance(Voltage outputVoltage) const = 0;

    /**
     * Returns whether a given resistance is a valid resistance for a thermistor
     * in this circuit model.
     *
     * @param  resistance the resistance to check
     * @return whether a given temperature is a valid input resistance for a
     *         thermistor in this circuit model.
     */
    virtual bool isValidThermistorResistance(Resistance resistance) const = 0;

    virtual Voltage getOutputVoltage(Resistance thermistorResistance) const = 0;

    virtual Power getThermistorPowerDissipationAtResistance(Resistance Rt) const = 0;

    virtual Power getThermistorPowerDissipationAtOutputVoltage(Voltage Vout) const = 0;

    virtual void accept(CircuitVisitor* visitor) const = 0;

  private:
    friend class boost::serialization::access;
    template<class Archive> void serialize(Archive & ar, unsigned int version)
    {
      if (version != 0) {
        throw SerializationException("Unknown version " + 
				     boost::lexical_cast<std::string>(version) + " for Circuit.");
      }
    }
  };

}

BOOST_CLASS_VERSION(tltgen::Circuit, 0)

#endif
